#include"process_bar.h"
const char* str = "|/-\\";
void process_bar(double rate)
{
    static char bar[SIZE] = { 0 };
    static int cnt = 0;
    int num = strlen(str);
    if (rate <= MAX_RATE && rate >= 0)
    {
        cnt++;
        cnt = (cnt >= num ? 0 : cnt); //cnt %= num;
        printf("[\033[30;47m % -100s\033[0m][% .1f % %][% c]\r",bar, rate, str[cnt]);
        fflush(stdout);
        if (rate < MAX_RATE)
        {
            bar[(int)rate] = STYLE; //'='
            bar[(int)rate + 1] = STYLE_HEADER; //'>'
        }
        else
        {
            bar[(int)rate] = STYLE;
        }
    }
}
